package com.patttern.creativity.singlenton;

/**
 * @Author: root
 * @Date: 2018/12/3 21:10
 * 双重校验锁单例模式
 */
public class Singleton03 {
    private static Singleton03 instance = null;

    private Singleton03() {
    }

    private static Singleton03 getInstance() {
        if (instance == null) {
            Singleton03 sc;
            synchronized (Singleton03.class) {
                sc = instance;
                if (sc == null) {
                    synchronized (Singleton03.class) {
                        if (sc == null) {
                            sc = new Singleton03();
                        }
                    }
                    instance = sc;
                }
            }
        }
        return instance;
    }
}
